from data_cleaning import load_and_clean_data
from financial_metrics import calculate_dupont
from visualization import plot_roe_trend, plot_stack_bar, plot_scatter
from regression_analysis import perform_regression

# 1. 数据读取与清洗
df = load_and_clean_data("data/financial_data.json")
print("✅ 原始数据清洗完成\n", df.head())

# 2. 杜邦指标计算
dupont_df = calculate_dupont(df)
print("\n✅ 杜邦指标计算结果:\n", dupont_df.head())

# 3. 绘制可视化图形
plot_roe_trend(dupont_df)
plot_stack_bar(dupont_df)
plot_scatter(dupont_df)

# 4. 回归分析
results = perform_regression(dupont_df)
print("\n✅ 回归结果：")
for company, info in results.items():
    print(f"\n📊 {company}")
    print("回归系数:", info["coef"])
    print("截距:", info["intercept"])
    print("R²值:", info["r2"])
